package iflyer.web;

import iflyer.model.User;
import iflyer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author babylct
 * @Description //TODO
 * @Date 20:38 2018/7/20
 * @Param
 * @return
 **/
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "{name}/user", method = RequestMethod.GET)
    public User getUserInfo(@PathVariable(name = "name") String name) {
        User user = userService.getUser(name);
        return user;
    }

    @RequestMapping(value = "/save/{name}/{age}", method = RequestMethod.GET)
    public User saveUserInfo(@PathVariable(name = "name") String name, @PathVariable(name = "age") String age) {
        User user = userService.saveUser(name, age);
        return user;
    }

}